package com.ram.service.impl;

import com.ram.mapper.BedMapper;
import com.ram.pojo.Bed;
import com.ram.pojo.BedDTO;
import com.ram.pojo.BedVO;
import com.ram.pojo.PageResult;
import com.ram.service.BedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BedServiceImpl implements BedService {
    @Autowired
    private BedMapper bedMapper;

    @Override
    public List<Bed> list(Integer roomId) {
        return bedMapper.list(roomId);
    }

    @Override
    public Bed getById(Integer id) {
        return bedMapper.getById(id);
    }

    @Override
    public void add(Bed bed) {
        bedMapper.insert(bed);
    }

    @Override
    public void update(Bed bed) {
        bedMapper.update(bed);
    }

    @Override
    public void deleteById(Integer id) {
        bedMapper.deleteById(id);
    }

    @Override
    public PageResult<BedVO> pageQuery(BedDTO dto) {
        // PageHelper.startPage(dto.getPage(), dto.getPageSize());
        List<BedVO> list = bedMapper.pageQuery(dto);
        long total = bedMapper.countPageQuery(dto);
        return new PageResult<>(total, list);
    }
} 